#pragma once
typedef struct
{
    unsigned long user_time;
    unsigned long nice_time;
    unsigned long system_time;
    unsigned long idle_time;
    unsigned long iowait_time;
    unsigned long irq_time;
    unsigned long softirq_time;
    unsigned long steal_time;
    unsigned long guest_time;
    unsigned long guest_nice_time;
    double timestamp;
    // 计算值
    double used_time;
    double total_time;
    double usage;
} cpu_time_t;

typedef struct
{
    cpu_time_t cpu_all;
    unsigned long cpu_num;
    cpu_time_t cpus[];
} Cpu_Time;

Cpu_Time* init_cpu_time(Cpu_Time** cpu_time);
void free_cpu_time(Cpu_Time* cpu_time);

int get_cpu_time(Cpu_Time* cpu_time);
void show_cpu_time(Cpu_Time* cpu_time);

int cal_cpu_usage(Cpu_Time* last_cpu_time, Cpu_Time* now_cpu_time);
void show_cpu_usage(Cpu_Time* now_cpu_time);
